package com.gin.no_gay_alliance.viewmodel;

import android.os.Parcel;
import android.os.Parcelable;

import com.gin.nga.response.field.Reputation;

/**
 * 声望信息
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/7 00:30
 **/
public class ReputationModel implements Parcelable {
    public static final Creator<ReputationModel> CREATOR = new Creator<ReputationModel>() {
        @Override
        public ReputationModel createFromParcel(Parcel in) {
            return new ReputationModel(in);
        }

        @Override
        public ReputationModel[] newArray(int size) {
            return new ReputationModel[size];
        }
    };
    public String name;
    public Integer value;
    public String remark;

    public ReputationModel(Reputation reputation) {
        name = reputation.getName();
        value = reputation.getValue();
        remark = reputation.getRemark();
    }

    protected ReputationModel(Parcel in) {
        name = in.readString();
        if (in.readByte() == 0) {
            value = null;
        } else {
            value = in.readInt();
        }
        remark = in.readString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
        if (value == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(value);
        }
        dest.writeString(remark);
    }
}
